package com.bungarus.rm.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * Created by tang on 2019/1/13.
 */
@Component
public class UniqueNodeID implements Serializable {
    @JsonProperty("cluster")
    private int clusterId;

    @JsonProperty("node")
    private int nodeId;

    public UniqueNodeID(int clusterId, int nodeId) {
        this.clusterId = clusterId;
        this.nodeId = nodeId;
    }

    public UniqueNodeID() {
    }

    @Override
    public String toString() {
        return "UniqueNodeID{" +
                "clusterId=" + clusterId +
                ", nodeId=" + nodeId +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof UniqueNodeID)) return false;

        UniqueNodeID that = (UniqueNodeID) o;

        if (getClusterId() != that.getClusterId()) return false;
        return getNodeId() == that.getNodeId();

    }

    @Override
    public int hashCode() {
        int result = getClusterId();
        result = 31 * result + getNodeId();
        return result;
    }

    public int getClusterId() {
        return clusterId;
    }

    public void setClusterId(int clusterId) {
        this.clusterId = clusterId;
    }

    public int getNodeId() {
        return nodeId;
    }

    public void setNodeId(int nodeId) {
        this.nodeId = nodeId;
    }
}
